package com.xbongbong.saas.script.tempenum;

import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.LinkDetailPojo;
import com.xbongbong.paas.field.SerialNumberPoJo;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.OriStockEnum;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 *
 * @author cyy
 * @date 2019/
 * @since v1.0
 * @version v1.0
 */
@Getter
public enum TempOriStockEnum {
    // 基本信息
    BASE_INFO(OriStockEnum.BASE_INFO),
    ORI_STOCK_NO(OriStockEnum.ORI_STOCK_NO),
    WAREHOUSE(OriStockEnum.WAREHOUSE),
    PRODUCT_DETAIL(OriStockEnum.PRODUCT_DETAIL),
    // 系统信息
    SYSTEM_INFO(OriStockEnum.SYSTEM_INFO),
    CREATOR_ID(OriStockEnum.CREATOR_ID),
    ADD_TIME(OriStockEnum.ADD_TIME),
    UPDATE_TIME(OriStockEnum.UPDATE_TIME),
    // 隐藏字段
    WAREHOUSE_LINK_TEXT(OriStockEnum.WAREHOUSE_LINK_TEXT),
    ;
    private OriStockEnum anEnum;

    TempOriStockEnum(OriStockEnum anEnum) {
        this.anEnum = anEnum;
    }

    public static List<TempOriStockEnum> getAllEnum() {
        List<TempOriStockEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }
    /**
     * 初始化期初库存编号
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initOriStockNo(FieldAttrEntity fieldAttrEntity){
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.ORI_STOCK.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.ORI_STOCK.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(ORI_STOCK_NO.getAnEnum().getAttr());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        fieldAttrEntity.setNoRepeat(1);
        fieldAttrEntity.setIsForbidden(0);

        SerialNumberPoJo serialNumberPoJo = InitExplainsHelper.setSerialNumber(SerialNumberEnum.ORI_STOCK_NO);
        fieldAttrEntity.setSerialNumber(serialNumberPoJo);

    }
//    public static void initProductDetailSubForm(FieldAttrEntity fieldAttrEntity) {
//        SubFormPoJo subFormPoJo = new SubFormPoJo();
//        JSONArray items = new JSONArray();
//        FieldAttrEntity specification = InitExplainsHelper.setField("array_1", "产品名称", "specification", FieldTypeEnum.CASCADER.getType(), 4, ShowTypeEnum.ALL.getCode(), 0, 1);
//        specification.setRequired(1);
//        specification.setDictionaryFlag(1);
//        specification.setParentAttr(PRODUCT_DETAIL.anEnum.getAttr());
//        items.add(specification);
//
//        FieldAttrEntity warehouseName = InitExplainsHelper.setField("array_2", "产品编码", "warehouseName", FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(), 4, ShowTypeEnum.ALL.getCode(), 0, 1);
//        warehouseName.setNoRepeat(0);
//        warehouseName.setParentAttr(PRODUCT_DETAIL.anEnum.getAttr());
//        warehouseName.setLinkedType(XbbRefTypeEnum.WAREHOUSE.getCode());
//        warehouseName.setRequired(1);
//        items.add(warehouseName);
//
//        FieldAttrEntity stockMin = InitExplainsHelper.setField("num_3", "规格", "stockLowerLimit", FieldTypeEnum.NUM.getType(), 4, ShowTypeEnum.ALL.getCode(), 0, 1);
//        stockMin.setNoRepeat(0);
//        stockMin.setParentAttr(PRODUCT_DETAIL.anEnum.getAttr());
//        stockMin.setRequired(1);
//        items.add(stockMin);
//
//        FieldAttrEntity stockMax = InitExplainsHelper.setField("num_4", "条形码", "stockUpperLimit", FieldTypeEnum.NUM.getType(), 4, ShowTypeEnum.ALL.getCode(), 0, 1);
//        stockMax.setNoRepeat(0);
//        stockMax.setParentAttr(PRODUCT_DETAIL.anEnum.getAttr());
//        stockMax.setRequired(1);
//        items.add(stockMax);
//
//        FieldAttrEntity stockMax = InitExplainsHelper.setField("num_4", "期初数量", "stockUpperLimit", FieldTypeEnum.NUM.getType(), 4, ShowTypeEnum.ALL.getCode(), 0, 1);
//        stockMax.setNoRepeat(0);
//        stockMax.setParentAttr(PRODUCT_DETAIL.anEnum.getAttr());
//        stockMax.setRequired(1);
//        items.add(stockMax);
//
//        FieldAttrEntity stockMax = InitExplainsHelper.setField("num_4", "备注", "stockUpperLimit", FieldTypeEnum.NUM.getType(), 4, ShowTypeEnum.ALL.getCode(), 0, 1);
//        stockMax.setNoRepeat(0);
//        stockMax.setParentAttr(PRODUCT_DETAIL.anEnum.getAttr());
//        stockMax.setRequired(1);
//        items.add(stockMax);
//
//        subFormPoJo.setItems(items);
//        fieldAttrEntity.setSubForm(subFormPoJo);
////        DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
////        defaultAttrPoJo.setDefaultType(DefaultTypeEnum.CUSTOM.getAlias());
////        fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
//        fieldAttrEntity.setRequired(1);
//        fieldAttrEntity.setDictionaryFlag(1);
//        fieldAttrEntity.setIsForbidden(0);
//    }
}
